/*********************************************************************
 *                                                                   *
 *  Js Css Minifier ( JsCssMin )                                     *
 *  Author: Igor Kanshyn                                             *
 *  Copyright (c) 2009, Igor Kanshyn. All rights reserved.           *
 *                                                                   *
 *  JsCssMin is released under the Apache Software License.          *
 *  See LICENSE.txt for more details.                                *
 *                                                                   *
 *********************************************************************/

package org.grenader.jscssmin.files;

import org.grenader.jscssmin.model.Resource;
import org.grenader.jscssmin.model.ResourceGroup;

import java.io.File;
import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * <p>Product: JsCssMin ( JavaScript and CSS Minifier )<br>
 * Author: Igor Kanshyn (grenader).
 * </p>
 * Date: Apr 26, 2009
 */
public class ResourceTmpFileIterator implements Iterator<File> {
    private Iterator<Resource> resourceIterator;

    public ResourceTmpFileIterator(ResourceGroup group) {
        resourceIterator = group.getResources().iterator();
    }

    public boolean hasNext() {
        return resourceIterator.hasNext();
    }

    public File next() {
        String tmpFile = resourceIterator.next().getTmpFile();
        if (tmpFile == null || tmpFile.isEmpty())
            throw new NoSuchElementException("tmp file can't be null!");
        return new File(tmpFile);
    }

    public void remove() {
        throw new IllegalAccessError("This method should not be called.");
    }
}